﻿using FairyGUI;

/// <summary>
/// IP地址提示
/// </summary>
public class UIGameIpTip : UIPopupWindow
{
	static UIGameIpTip _inst;
	public UIGameIpTip (string msg)
	{
		_inst = this;

		// 加载界面
		base.Init (UIPackage.CreateObject ("游戏界面", "地址提示框").asCom);

		// 初始化关闭按钮
		GButton closeBtn = uiComp.GetChild ("关闭按钮").asButton;
		closeBtn.onClick.Add (() => {
			_Close();
		});

		GTextField textMsg = uiComp.GetChild ("提示").asTextField;
		textMsg.text = msg;
	}

	void _Close() {
		DebugInfo.Log ("关闭 地址提示框");

		AudioController.inst.PlayUIClickEffect ();
		uiComp.RemoveFromParent ();
		uiComp.Dispose ();
		base.Close ();

		_inst = null;
	}

	public static void CloseWindow() {
		if (_inst != null) {
			_inst._Close ();
		}
	}

	/// <summary>
	/// 弹出窗口
	/// </summary>
	public static void Popup (string msg)
	{
		DebugInfo.Log ("打开 地址提示框");
		UIRootController.inst.PopupWindow (new UIGameIpTip (msg));
	}
}
